<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2018/6/21
 * Time: 16:50
 */

namespace app\common\model;

use app\common\lib\exception\ApiException;
use think\Cache;

class HeSijiaoText extends Base
{
    /**
     * 获取所有合轴词条
     */
    public function getHeSijiaoText()
    {
        $data = false;

        if ((int)($this->cache_on >= 1))
        {
            $data = Cache::get('he_sijiao_text');
        }

        if ($data === false)
        {
            try
            {
                $data = $this
                    ->where('status',1)
                    ->selectOrFail();
                $data = json_decode(json_encode($data, true), true);
            } catch (\Exception $e)
            {
                $data = [];
            }

            if ($this->cache_on >= 1)
            {
                $temp = [];
                foreach ($data as $d) $temp[$d['planet']] = $d;
                $data = $temp;
                Cache::set('he_sijiao_text', $data, 86400 * 7);
            }
        }

        return $data;
    }

}
